#include "gd32f3x0.h"
#include "Systick_Ctrl.h"
#include "Msg.h"

extern unsigned int g_SystickIRQs;
int tick_count = 0;
static uint32_t gTimingDelay = 0;

void Systick_IRQHandler(void)
{
    tick_count++;
    if(tick_count == 100)/*1000 10s;100 1s*/
    {
        g_SystickIRQs += 1;
        tick_count = 0;
		
    }

    if(gTimingDelay != 0)
    {
        gTimingDelay--;
    }
}

void Systick_Config(void)
{
    if(SysTick_Config(SystemCoreClock / 100))
    {
        while(1);
    }
    NVIC_SetPriority(SysTick_IRQn, 0x00);
}

void Systick_Delay(unsigned int ms)
{
    gTimingDelay = ms / 10;
    if(gTimingDelay == 0)
    {
        gTimingDelay = 1;
    }

    while(gTimingDelay != 0);
}

